﻿using System;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;

namespace shenghua.Migrations
{
    public partial class addentity4 : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropColumn(
                name: "Info_DiscountAmount_MoneyType",
                table: "Orders");

            migrationBuilder.DropColumn(
                name: "Info_DiscountAmount_Value",
                table: "Orders");

            migrationBuilder.RenameColumn(
                name: "Info_OrderNumber",
                table: "Orders",
                newName: "OrderNumber");

            migrationBuilder.RenameColumn(
                name: "Price_Value",
                table: "Commodities",
                newName: "ShoppingInfo_Price_Value");

            migrationBuilder.RenameColumn(
                name: "Price_MoneyType",
                table: "Commodities",
                newName: "ShoppingInfo_Price_MoneyType");

            migrationBuilder.RenameColumn(
                name: "XPValue",
                table: "Commodities",
                newName: "ShoppingInfo_XPValue");

            migrationBuilder.RenameColumn(
                name: "Inventory",
                table: "Commodities",
                newName: "ShoppingInfo_Inventory");

            migrationBuilder.AddColumn<double>(
                name: "AddedFreightValue",
                table: "WordNodes",
                nullable: true);

            migrationBuilder.AddColumn<int>(
                name: "AddedNumber",
                table: "WordNodes",
                nullable: true);

            migrationBuilder.AddColumn<int>(
                name: "FirstNumber",
                table: "WordNodes",
                nullable: true);

            migrationBuilder.AddColumn<int>(
                name: "TemplateType",
                table: "WordNodes",
                nullable: true);

            migrationBuilder.AddColumn<int>(
                name: "PaymentInfo_PaymentType",
                table: "Orders",
                nullable: false,
                defaultValue: 0);

            migrationBuilder.AddColumn<int>(
                name: "TotalAmount_MoneyType",
                table: "OrderDetails",
                nullable: false,
                defaultValue: 0);

            migrationBuilder.AddColumn<double>(
                name: "TotalAmount_Value",
                table: "OrderDetails",
                nullable: false,
                defaultValue: 0.0);

            migrationBuilder.AddColumn<int>(
                name: "TargetType",
                table: "Coupons",
                nullable: false,
                defaultValue: 0);

            migrationBuilder.AddColumn<int>(
                name: "CommodityWareId",
                table: "Commodities",
                nullable: false,
                defaultValue: 0);

            migrationBuilder.AddColumn<DateTime>(
                name: "CreationTime",
                table: "Commodities",
                nullable: false,
                defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));

            migrationBuilder.AddColumn<long>(
                name: "CreatorUserId",
                table: "Commodities",
                nullable: true);

            migrationBuilder.AddColumn<bool>(
                name: "Discountable",
                table: "Commodities",
                nullable: false,
                defaultValue: false);

            migrationBuilder.AddColumn<string>(
                name: "ExtensionData",
                table: "Commodities",
                nullable: true);

            migrationBuilder.AddColumn<bool>(
                name: "IsDiscountPerLevel",
                table: "Commodities",
                nullable: false,
                defaultValue: false);

            migrationBuilder.AddColumn<bool>(
                name: "IsEnabledShoppingOption",
                table: "Commodities",
                nullable: false,
                defaultValue: false);

            migrationBuilder.AddColumn<bool>(
                name: "IsRecommended",
                table: "Commodities",
                nullable: false,
                defaultValue: false);

            migrationBuilder.AddColumn<bool>(
                name: "Shelved",
                table: "Commodities",
                nullable: false,
                defaultValue: false);

            migrationBuilder.AddColumn<string>(
                name: "Classes_Class1",
                table: "Commodities",
                nullable: true);

            migrationBuilder.AddColumn<string>(
                name: "Classes_Class2",
                table: "Commodities",
                nullable: true);

            migrationBuilder.AddColumn<string>(
                name: "Classes_Class3",
                table: "Commodities",
                nullable: true);

            migrationBuilder.AddColumn<int>(
                name: "ShoppingInfo_MaxLimitCount",
                table: "Commodities",
                nullable: false,
                defaultValue: 0);

            migrationBuilder.AddColumn<int>(
                name: "ShoppingInfo_MinLimitCount",
                table: "Commodities",
                nullable: false,
                defaultValue: 0);

            migrationBuilder.AddColumn<string>(
                name: "ShoppingInfo_Picture",
                table: "Commodities",
                nullable: true);

            migrationBuilder.CreateTable(
                name: "CommoditySpecifications",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    CommodityId = table.Column<long>(nullable: false),
                    Price_MoneyType = table.Column<int>(nullable: false),
                    Price_Value = table.Column<double>(nullable: false),
                    XPValue = table.Column<int>(nullable: false),
                    Inventory = table.Column<int>(nullable: false),
                    MinLimitCount = table.Column<int>(nullable: false),
                    MaxLimitCount = table.Column<int>(nullable: false),
                    Pictures_StringValue = table.Column<string>(nullable: true),
                    ExtensionData = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_CommoditySpecifications", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "SalesPromotions",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    Price_MoneyType = table.Column<int>(nullable: false),
                    Price_Value = table.Column<double>(nullable: false),
                    AppliedCommodityIds_StringValue = table.Column<string>(nullable: true),
                    TargetType = table.Column<int>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_SalesPromotions", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "WordNode",
                columns: table => new
                {
                    MoneyType = table.Column<int>(nullable: false),
                    Value = table.Column<double>(nullable: false),
                    ShippingTemplateId = table.Column<int>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_WordNode", x => x.ShippingTemplateId);
                    table.ForeignKey(
                        name: "FK_WordNode_WordNodes_ShippingTemplateId",
                        column: x => x.ShippingTemplateId,
                        principalTable: "WordNodes",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "CommoditySpecifications");

            migrationBuilder.DropTable(
                name: "SalesPromotions");

            migrationBuilder.DropTable(
                name: "WordNode");

            migrationBuilder.DropColumn(
                name: "AddedFreightValue",
                table: "WordNodes");

            migrationBuilder.DropColumn(
                name: "AddedNumber",
                table: "WordNodes");

            migrationBuilder.DropColumn(
                name: "FirstNumber",
                table: "WordNodes");

            migrationBuilder.DropColumn(
                name: "TemplateType",
                table: "WordNodes");

            migrationBuilder.DropColumn(
                name: "PaymentInfo_PaymentType",
                table: "Orders");

            migrationBuilder.DropColumn(
                name: "TotalAmount_MoneyType",
                table: "OrderDetails");

            migrationBuilder.DropColumn(
                name: "TotalAmount_Value",
                table: "OrderDetails");

            migrationBuilder.DropColumn(
                name: "TargetType",
                table: "Coupons");

            migrationBuilder.DropColumn(
                name: "CommodityWareId",
                table: "Commodities");

            migrationBuilder.DropColumn(
                name: "CreationTime",
                table: "Commodities");

            migrationBuilder.DropColumn(
                name: "CreatorUserId",
                table: "Commodities");

            migrationBuilder.DropColumn(
                name: "Discountable",
                table: "Commodities");

            migrationBuilder.DropColumn(
                name: "ExtensionData",
                table: "Commodities");

            migrationBuilder.DropColumn(
                name: "IsDiscountPerLevel",
                table: "Commodities");

            migrationBuilder.DropColumn(
                name: "IsEnabledShoppingOption",
                table: "Commodities");

            migrationBuilder.DropColumn(
                name: "IsRecommended",
                table: "Commodities");

            migrationBuilder.DropColumn(
                name: "Shelved",
                table: "Commodities");

            migrationBuilder.DropColumn(
                name: "Classes_Class1",
                table: "Commodities");

            migrationBuilder.DropColumn(
                name: "Classes_Class2",
                table: "Commodities");

            migrationBuilder.DropColumn(
                name: "Classes_Class3",
                table: "Commodities");

            migrationBuilder.DropColumn(
                name: "ShoppingInfo_MaxLimitCount",
                table: "Commodities");

            migrationBuilder.DropColumn(
                name: "ShoppingInfo_MinLimitCount",
                table: "Commodities");

            migrationBuilder.DropColumn(
                name: "ShoppingInfo_Picture",
                table: "Commodities");

            migrationBuilder.RenameColumn(
                name: "OrderNumber",
                table: "Orders",
                newName: "Info_OrderNumber");

            migrationBuilder.RenameColumn(
                name: "ShoppingInfo_Price_Value",
                table: "Commodities",
                newName: "Price_Value");

            migrationBuilder.RenameColumn(
                name: "ShoppingInfo_Price_MoneyType",
                table: "Commodities",
                newName: "Price_MoneyType");

            migrationBuilder.RenameColumn(
                name: "ShoppingInfo_XPValue",
                table: "Commodities",
                newName: "XPValue");

            migrationBuilder.RenameColumn(
                name: "ShoppingInfo_Inventory",
                table: "Commodities",
                newName: "Inventory");

            migrationBuilder.AddColumn<int>(
                name: "Info_DiscountAmount_MoneyType",
                table: "Orders",
                nullable: false,
                defaultValue: 0);

            migrationBuilder.AddColumn<double>(
                name: "Info_DiscountAmount_Value",
                table: "Orders",
                nullable: false,
                defaultValue: 0.0);
        }
    }
}
